#!/bin/bash

apt update

apt -y install nginx

apt -y install mariadb-server-10.3

apt install  ca-certificates apt-transport-https software-properties-common

add-apt-repository ppa:ondrej/php

apt update

apt install php8.0-fpm php8.0-bcmath php8.0-bz2 php8.0-curl php8.0-gd php8.0-intl php8.0-mbstring php8.0-mysql php8.0-mcrypt php8.0-xml php8.0-xsl -y


cd /etc/php/8.0/fpm/
mv php.ini php.ini.bak
curl -O https://gitee.com/shibaolin/shell/raw/master/php80/php.ini


cd /etc/nginx/sites-available/
mv default default.bak
curl -O https://gitee.com/shibaolin/shell/raw/master/php80/default

service php8.0-fpm restart
service nginx restart

createDB=`
mysql<<EOF
create database dodb default charset utf8mb4 collate utf8mb4_unicode_ci;
use dodb;
source /root/do.sql;
EOF
`
echo $createDB

read -p "Enter new password of root user: " password

if [ ! -n "$password" ]; then
    password="qwer9876"
fi

initmysql=`
mysql<<EOF
use mysql;
update user set authentication_string=PASSWORD('${password}') where User='root'; 
update user set plugin="mysql_native_password"; 
flush privileges;
EOF
`

echo $initmysql